// 拦截路径，代理地址，替换路径
export const localProxy = [
    ['/demo', 'http://103.88.99.2:12007', '/shield'],
    ['/vis-api', 'http://127.0.0.1:56789', ''],
]

export function creatLocalProxy() {
    const ret = {}
    for (const [prefix, target, replacePrefix] of localProxy) {
        const httpsRE = /^https:\/\//
        const isHttps = httpsRE.test(target)
        ret[prefix] = {
            target: target,
            prefix: prefix,
            replacePrefix: replacePrefix,
            changeOrigin: true,
            ws: true,
            rewrite: replacePrefix === undefined ? undefined : path => path.replace(new RegExp(`^${prefix}`), replacePrefix),
            // https is require secure=false
            ...(isHttps ? {secure: false} : {})
        }
    }
    console.log("\n【HTTP本地代理】\n", ret, "\n\n")
    return ret
}



